package com.yuno.mock.exception;

/**
 * Excel验证异常
 * 
 * @author yuno
 * @since 2024-01-01
 */
public class ExcelValidationException extends ExcelReadException {

    private String validationType;
    private Object expectedValue;
    private Object actualValue;

    public ExcelValidationException(String message) {
        super(message);
    }

    public ExcelValidationException(String message, Throwable cause) {
        super(message, cause);
    }

    public ExcelValidationException(String errorCode, String message) {
        super(errorCode, message);
    }

    public ExcelValidationException(String errorCode, String message, String validationType) {
        super(errorCode, message);
        this.validationType = validationType;
    }

    public ExcelValidationException(String errorCode, String message, String validationType, Object expectedValue, Object actualValue) {
        super(errorCode, message);
        this.validationType = validationType;
        this.expectedValue = expectedValue;
        this.actualValue = actualValue;
    }

    public ExcelValidationException(String errorCode, String message, String filePath, String sheetName, Integer rowNumber, Integer columnNumber, String validationType) {
        super(errorCode, message, filePath, sheetName, rowNumber, columnNumber);
        this.validationType = validationType;
    }

    // Getters
    public String getValidationType() {
        return validationType;
    }

    public Object getExpectedValue() {
        return expectedValue;
    }

    public Object getActualValue() {
        return actualValue;
    }

    // Setters
    public void setValidationType(String validationType) {
        this.validationType = validationType;
    }

    public void setExpectedValue(Object expectedValue) {
        this.expectedValue = expectedValue;
    }

    public void setActualValue(Object actualValue) {
        this.actualValue = actualValue;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("ExcelValidationException{");
        sb.append("errorCode='").append(getErrorCode()).append('\'');
        sb.append(", message='").append(getMessage()).append('\'');
        if (getFilePath() != null) {
            sb.append(", filePath='").append(getFilePath()).append('\'');
        }
        if (getSheetName() != null) {
            sb.append(", sheetName='").append(getSheetName()).append('\'');
        }
        if (getRowNumber() != null) {
            sb.append(", rowNumber=").append(getRowNumber());
        }
        if (getColumnNumber() != null) {
            sb.append(", columnNumber=").append(getColumnNumber());
        }
        if (validationType != null) {
            sb.append(", validationType='").append(validationType).append('\'');
        }
        if (expectedValue != null) {
            sb.append(", expectedValue=").append(expectedValue);
        }
        if (actualValue != null) {
            sb.append(", actualValue=").append(actualValue);
        }
        sb.append('}');
        return sb.toString();
    }
}